//
//  WYMainViewController.swift
//  WeiboWY
//
//  Created by mac on 16/5/1.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class WYMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewController(WYHomeTableViewController(), title: "首页", iconImage: "tabbar_home")
        addChildViewController(WYMessageTableViewController(), title: "消息", iconImage: "tabbar_message_center")
        addChildViewController(WYDiscoverTableViewController(), title: "发现", iconImage: "tabbar_discover")
        addChildViewController(WYProfileTableViewController(), title: "我的", iconImage: "tabbar_profile")
    }



    func addChildViewController(childController: UIViewController, title: String, iconImage: String) {
        
//        childController.tabBarItem.title = title
//        childController.navigationItem.title = title
        childController.title = title
        
        childController.tabBarItem.image = UIImage(named: iconImage)
        childController.tabBarItem.selectedImage = UIImage(named: iconImage + "_selected")?.imageWithRenderingMode(.AlwaysOriginal)
        childController.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orangeColor()], forState: .Selected)
        childController.tabBarItem.setTitleTextAttributes([NSFontAttributeName: UIFont.systemFontOfSize(14)], forState: .Normal)
        
        let nav = UINavigationController(rootViewController: childController)
        addChildViewController(nav)
    }


}
